class Solution
{
public:
    int oddCells(int m, int n, vector<vector<int>> &indices)
    {
        vector<int> rowAddCount(m, 0);
        vector<int> colAddCount(n, 0);
        for (auto &index : indices)
        {
            ++rowAddCount[index[0]];
            ++colAddCount[index[1]];
        }
        int rowAddOdd = 0;
        int colAddOdd = 0;
        for (int r : rowAddCount)
        {
            if (r & 1)
            {
                ++rowAddOdd;
            }
        }
        for (int c : colAddCount)
        {
            if (c & 1)
            {
                ++colAddOdd;
            }
        }
        return rowAddOdd * (n - colAddOdd) + colAddOdd * (m - rowAddOdd);
    }
};